package com.species.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author dries
 * @date 2022/3/19
 */
@RestController
@RequestMapping("/api")
public class HomeController extends BaseController {

    @Autowired
    private ISmsBannerService smsBannerService;
    @Autowired
    private ISysNoticeService noticeService;
    @Autowired
    private ISmsNewsService smsNewsService;
    @Autowired
    private ISmsDepartmentService smsDepartmentService;
    @Autowired
    private ISmsSpeciesService smsSpeciesService;

    /**
     * 查询首页轮播广告列表
     */
    @GetMapping("/sms/banner/list")
    public TableDataInfo list(SmsBanner smsBanner) {
        startPage();
        List<SmsBanner> list = smsBannerService.selectSmsBannerList(smsBanner);
        return getDataTable(list);
    }

    /**
     * 获取通知公告列表
     */
    @GetMapping("/sms/notice/list")
    public TableDataInfo list(SysNotice notice) {
        startPage();
        List<SysNotice> list = noticeService.queryNoticeList(notice);
        return getDataTable(list);
    }

    /**
     * 获取通知公告详情
     */
    @GetMapping("/sms/notice/detail")
    public AjaxResult noticeDetail(@RequestParam String nId) {
        return AjaxResult.success(noticeService.selectNoticeById(Long.valueOf(nId)));
    }

    /**
     * 查询新闻列表
     */
    @GetMapping("/sms/news/list")
    public TableDataInfo list(SmsNews smsNews) {
        startPage();
        List<SmsNews> list = smsNewsService.queryNoticeList(smsNews);
        return getDataTable(list);
    }

    /**
     * 查询新闻详情
     */
    @GetMapping("/sms/news/detail")
    public AjaxResult newsDetail(@RequestParam String nId) {
        return AjaxResult.success(smsNewsService.selectSmsNewsById(Long.valueOf(nId)));
    }

    /**
     * 查询检举部门列表
     */
    @GetMapping("/sms/department/list")
    public TableDataInfo departmentList(SmsDepartment smsDepartment)
    {
        startPage();
        List<SmsDepartment> list = smsDepartmentService.selectSmsDepartmentList(smsDepartment);
        return getDataTable(list);
    }

    /**
     * 查询检举部门详情
     */
    @GetMapping("/sms/department/info")
    public AjaxResult departmentInfo(@RequestParam Long id)
    {
        return AjaxResult.success(smsDepartmentService.selectSmsDepartmentById(id));
    }

    /**
     * 查询物种列表
     */
    @GetMapping("/sms/species/list")
    public TableDataInfo speciesList(SmsSpecies smsSpecies)
    {
        startPage();
        List<SmsSpecies> list = smsSpeciesService.selectSmsSpeciesList(smsSpecies);
        return getDataTable(list);
    }

    /**
     * 获取物种详细信息
     */
    @GetMapping(value = "/sms/species/info")
    public AjaxResult getSpeciesInfo(@RequestParam Long id)
    {
        return AjaxResult.success(smsSpeciesService.selectSmsSpeciesById(id));
    }

    @Autowired
    private ISmsPrizeService smsPrizeService;

    /**
     * 查询奖品列表
     */
    @GetMapping("/sms/prize/list")
    public TableDataInfo prizeList(SmsPrize smsPrize)
    {
        startPage();
        List<SmsPrize> list = smsPrizeService.selectSmsPrizeList(smsPrize);
        return getDataTable(list);
    }

    /**
     * 获取奖品详细信息
     */
    @GetMapping(value = "/sms/prize/info")
    public AjaxResult getPrizeInfo(@RequestParam Long id)
    {
        return AjaxResult.success(smsPrizeService.selectSmsPrizeById(id));
    }
}
